﻿Public Class wfrmHTML
    Inherits System.Web.UI.Page

    Private Sub wfrmHTML_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Me.IsPostBack Then
            listar()
        End If
    End Sub



    Protected Sub listar()
        Dim ds As New DataSet
        ds.ReadXml(Server.MapPath("/DatalistXML/MenuOpcoes.xml"))

        Dim dtc As DataTableCollection = ds.Tables()
        Dim dtLista As New DataTable
        dtLista.Columns.Add("NomeTabela", GetType(String))
        For Each dt As DataTable In ds.Tables()
            Dim dr As DataRow = dtLista.NewRow()
            dr("NomeTabela") = dt.TableName
            dtLista.Rows.Add(dr)
        Next
        dtMenu.DataSource = dtLista
        dtMenu.DataBind()

        For Each dtItem As DataListItem In dtMenu.Items
            Dim dtLinks As DataList = dtItem.FindControl("dtLinks")
            encheLinks(dtItem.ItemIndex, dtLinks)
        Next

    End Sub

    Private Sub encheLinks(ByVal i As Integer, ByVal dtlist As DataList)
        Dim ds As New DataSet
        ds.ReadXml(Server.MapPath("/DatalistXML/MenuOpcoes.xml"))
        dtlist.DataSource = ds.Tables(i)
        dtlist.DataBind()
    End Sub

    Private Sub dtMenu_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dtMenu.ItemCommand
        If e.CommandName = "cor" Then
            Dim Label1 As Label = e.Item.FindControl("Label1")
            label1.ForeColor = Drawing.Color.DarkRed
        End If
    End Sub
End Class